package wildlife;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionMessage;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.*;
public class userImage {
File image;

public File getImage() {
	return image;
}

public void setImage(File image) {
	this.image = image;
}
public String execute() throws Exception{
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/wildlife","root","adithri");
	HttpServletRequest request=ServletActionContext.getRequest();
	HttpSession session=request.getSession();
	String username=session.getAttribute("username").toString();
	Connect c=new Connect();
	FileInputStream fis=new FileInputStream(image);
	PreparedStatement ps=con.prepareStatement("insert into image(username,image) values(?,?)");
	ps.setString(1,username);
	ps.setBinaryStream(2,(InputStream)fis,(int)image.length());
	ps.executeUpdate();
	return "success";
	
	
}
}
